<?php

namespace app\index\controller;

use think\Controller;
use think\View;

class Search extends Common
{
    public function index($keywords)
    {
//        dump($keywords);die;
        $key = input('keywords');
//        dump($key);die;

            $searchres= db('article')->order('id desc')->where('title','like','%'.$key.'%')->select();
//        dump($searchres);die;
        if ($searchres){
            $this->assign('searchres',$searchres);
            return \view('search');
        }else{
            $this->error('没有该关键词');
        }
    }
}
